home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1997
/
HAM Radio 1997.iso
/
vcls
/
srctt26
/
previnst.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-04-08
|
896b
|
43 lines
unit PrevInst;
interface
uses WinProcs, WinTypes, SysUtils;
type
PHWnd = ^HWnd;
function EnumFunc(Wnd : HWnd; TargetWindow : PHWnd): Bool; export;
procedure ActivatePreviousInstance;
implementation
function EnumFunc(Wnd : HWnd; TargetWindow : PHWnd): Bool;
var
ClassName : array [0..30] of char;
begin
Result := True;
if GetWindowWord(Wnd,GWW_HINSTANCE) = HPrevInst then begin
GetClassName(Wnd,ClassName,30);
if StrIComp(ClassName,'TApplication') = 0 then begin
TargetWindow^ := Wnd;
Result := False;
end;
end;
end;
procedure ActivatePreviousInstance;
var
PrevInstWnd : HWnd;
begin
PrevInstWnd := 0;
EnumWindows(@EnumFunc,Longint(@PrevInstWnd));
if PrevInstWnd <> 0 then
if IsIconic(PrevInstWnd) then
ShowWindow(PrevInstWnd,SW_RESTORE)
else
BringWindowToTop(PrevInstWnd);
end;
end.